home *** CD-ROM | disk | FTP | other *** search
/ The National Palace Museum Experience / The National Palace Museum Experience.iso / Programs / Panorama.dxr / 00090_control handlers.ls < prev    next >
Encoding:
Text File  |  1998-11-19  |  4.4 KB  |  152 lines

  1. global gsbmouseupslist, gsbmousedownslist, sbcontentsprite, sbhiliterect, scrollpos, scrolllinesize, roomnumber, light, objectpict
  2.  
  3. on initsbcontrols
  4.   set gsbmousedownslist to []
  5.   set gsbmouseupslist to []
  6.   setAt(gsbmouseupslist, sbhiliterect, 0)
  7.   setAt(gsbmousedownslist, sbhiliterect, 0)
  8. end
  9.  
  10. on addsbcontrol channel, chotspots, cactions, whichway
  11.   if not listp(chotspots) or not listp(cactions) then
  12.     return #badcontrol
  13.   end if
  14.   if count(chotspots) <> count(cactions) then
  15.     return #badcontrol
  16.   end if
  17.   if whichway = #down then
  18.     setAt(gsbmousedownslist, channel, [chotspots, cactions])
  19.   else
  20.     setAt(gsbmouseupslist, channel, [chotspots, cactions])
  21.   end if
  22. end
  23.  
  24. on deletesbcontrol channel, whichway
  25.   if (whichway = #up) or (whichway = #both) then
  26.     setAt(gsbmouseupslist, channel, 0)
  27.   end if
  28.   if (whichway = #down) or (whichway = #both) then
  29.     setAt(gsbmousedownslist, channel, 0)
  30.   end if
  31. end
  32.  
  33. on hitsbcontrol whichway
  34.   set me to the clickOn
  35.   set hitpoint to point(the mouseH - the left of sprite me, the mouseV - the top of sprite me)
  36.   if whichway = #down then
  37.     set controlslist to gsbmousedownslist
  38.     puppetSound(3, "Button")
  39.   else
  40.     set controlslist to gsbmouseupslist
  41.   end if
  42.   set mycontrol to getAt(controlslist, me)
  43.   if not listp(mycontrol) then
  44.     return #notcontrol
  45.   end if
  46.   if count(mycontrol) < 2 then
  47.     return #notcontrol
  48.   end if
  49.   set hitlist to getAt(mycontrol, 1)
  50.   if not listp(hitlist) then
  51.     return #notcontrol
  52.   end if
  53.   set actionlist to getAt(mycontrol, 2)
  54.   if not listp(actionlist) then
  55.     return #notcontrol
  56.   end if
  57.   if (count(actionlist) <> count(hitlist)) or (count(hitlist) = 0) then
  58.     return #badcontrol
  59.   end if
  60.   repeat with i = 1 to count(hitlist)
  61.     if inside(hitpoint, getAt(hitlist, i)) then
  62.       puppetSprite(sbhiliterect, 0)
  63.       puppetSprite(14, 0)
  64.       do(getAt(actionlist, i))
  65.       exit repeat
  66.     end if
  67.   end repeat
  68. end
  69.  
  70. on checksbrollover whichway
  71.   set noroll to 1
  72.   repeat with i = sbhiliterect - 1 down to 1
  73.     if rollOver(i) then
  74.       if (listp(getAt(gsbmouseupslist, i)) and ((whichway = #up) or (whichway = #both))) or (listp(getAt(gsbmousedownslist, i)) and ((whichway = #down) or (whichway = #both))) then
  75.         hilitesbcontrol(i, whichway)
  76.         set noroll to 0
  77.         exit repeat
  78.       end if
  79.     end if
  80.   end repeat
  81.   if noroll then
  82.     set the locH of sprite sbhiliterect to -1000
  83.     set the visible of sprite objectpict to 0
  84.     set the visible of sprite light to 0
  85.   end if
  86. end
  87.  
  88. on hilitesbcontrol contnum, whichway
  89.   set norect to 1
  90.   if (whichway = #up) or (whichway = #both) then
  91.     set upcont to getAt(gsbmouseupslist, contnum)
  92.     if not listp(upcont) then
  93.       set uprects to []
  94.     end if
  95.     if count(upcont) < 2 then
  96.       set uprects to []
  97.     end if
  98.     if voidp(uprects) then
  99.       set uprects to getAt(upcont, 1)
  100.     else
  101.       nothing()
  102.     end if
  103.   else
  104.     set uprects to []
  105.   end if
  106.   if (whichway = #down) or (whichway = #both) then
  107.     set downcont to getAt(gsbmousedownslist, contnum)
  108.     if not listp(downcont) then
  109.       set downrects to []
  110.     end if
  111.     if count(downcont) < 2 then
  112.       set downrects to []
  113.     end if
  114.     if voidp(downrects) then
  115.       set downrects to getAt(downcont, 1)
  116.     else
  117.       nothing()
  118.     end if
  119.   else
  120.     set downrects to []
  121.   end if
  122.   set rectlist to combo(uprects, downrects)
  123.   set hoff to the left of sprite contnum
  124.   set voff to the top of sprite contnum
  125.   set where to point(the mouseH - hoff, the mouseV - voff)
  126.   set mouseposition to point(the mouseH, the mouseV)
  127.   repeat with r in rectlist
  128.     if inside(where, r) then
  129.       set order to getOne(rectlist, r)
  130.       set smallpict to "A" & char 2 to 7 of word 2 of getAt(actslist, order) & "1"
  131.       if the number of member smallpict > 0 then
  132.         set the visible of sprite objectpict to 1
  133.         set the visible of sprite light to 1
  134.         updateStage()
  135.         swapmember(objectpict, smallpict, 1)
  136.       else
  137.         set the visible of sprite objectpict to 0
  138.         set the visible of sprite light to 0
  139.       end if
  140.       spriteBox(sbhiliterect, getAt(r, 1) + hoff, getAt(r, 2) + voff, getAt(r, 3) + hoff, getAt(r, 4) + voff)
  141.       updateStage()
  142.       set norect to 0
  143.       exit repeat
  144.     end if
  145.   end repeat
  146.   if norect or not rollOver(sbcontentsprite) then
  147.     set the locH of sprite sbhiliterect to -1000
  148.     set the visible of sprite objectpict to 0
  149.     set the visible of sprite light to 0
  150.   end if
  151. end
  152.